package com.bsbc.project.controller;

import com.bsbc.project.config.OperationAuth;
import org.junit.Test;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Method;

@RestController
public class OperationController {


    public void operation(){
        process(TestController.class);
    }


    /**
     * 通过反射获取注解属性
     * @param clazz
     */
    public void process(Class<?> clazz) {
        for (Method method : clazz.getDeclaredMethods()) {
            if (method.isAnnotationPresent(OperationAuth.class)) {
                OperationAuth annotation = method.getAnnotation(OperationAuth.class);
                System.out.println("带有注解的方法名: " + method.getName());
                System.out.println("Value: " + annotation.value());
                System.out.println("Count: " + annotation.sum());
            }
        }
    }
}
